import Vue from 'vue'
import VueRouter from 'vue-router'
import Layout from '@/views/layout/LayoutIndex.vue'
import Home from '@/views/layout/content/home/Home.vue'
import Login from '@/views/login/LoginIndex.vue'

// 异步引入组件
const Product = ()=>import('@/views/layout/content/product/Index.vue')
const ProductList = ()=>import('@/views/layout/content/product/list/Index.vue')
const ProductCategory = ()=>import('@/views/layout/content/product/category/Index.vue')

const Order = ()=>import('@/views/layout/content/order/Index.vue')
const OrderList = ()=>import('@/views/layout/content/order/list/Index.vue')
const OrderCollect = ()=>import('@/views/layout/content/order/collect/Index.vue')
const OrderExamine = ()=>import('@/views/layout/content/order/examine/Index.vue')

const Advert = ()=>import('@/views/layout/content/advert/Index.vue')
const AdvertList = ()=>import('@/views/layout/content/advert/list/Index.vue')

Vue.use(VueRouter)

const routes = [
    {
      path:'/',
      component:Layout,
      children:[
        {
          name:'home',
          path:'/',
          component:Home
        },
        {
          name:'product',
          path:'/product',
          component:Product,
          children:[
            {
              name:'list',
              path:'list',
              component:ProductList
            },
            {
              name:'category',
              path:'category',
              component:ProductCategory
            }
          ]
        },
        {
          name:'order',
          path:'/order',
          component:Order,
          children:[
            {
              name:'order-list',
              path:'order-list',
              component:OrderList,
            },
            {
              name:'order-collect',
              path:'order-collect',
              component:OrderCollect,
            },
            {
              name:'order-examine',
              path:'order-examine',
              component:OrderExamine,
            },
          ]
        },
        {
          name:'advert',
          path:'/advert',
          component:Advert,
          children:[
            {
              name:'advert-list',
              path:'advert-list',
              component:AdvertList
            },
          ]
        },
      ]
    },
    {
      name:'login',
      path:'/login',
      component:Login,
    }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
